let sys_sequelize = require("../../dao/sequelize/sys");
let login_util = require("../../util/login_util");
let auth_service = require("../../service/auth_service");
let crypto = require("crypto");
let strings = require("../../strings");
const Op = require("sequelize").Op;

module.exports = [
  {
    public: true,
    method: "post",
    path: "/sys/login",
    callback: async (ctx, next) => {
      let account = ctx.request.body.data.account;
      let password = ctx.request.body.data.password;
      if (!account) {
        ctx.pass_result = {
          success: false,
          message: strings.account_not_null
        };
        return next();
      }

      if (!password) {
        ctx.pass_result = {
          success: false,
          message: strings.password_not_null
        };
        return next();
      }

      ctx.pass_result = await auth_service.login(account, password);
      return next();
    }
  }
];
